package com.whfc.emp.dpa.queue;

import com.alibaba.fastjson.JSON;
import com.whfc.common.constant.QueueConst;
import com.whfc.emp.manager.AppFaceGateManager;
import com.whfc.emp.param.EmpGroupSyncDataParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-08-05 17:33
 */
@Component
@RabbitListener(queues = QueueConst.EMP_FACEGATE_GROUP_DATA)
public class FaceGateGroupSyncQueueMessageListener {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AppFaceGateManager appFaceGateManager;

    @RabbitHandler
    public void process(String msg) {
        try {
            logger.info("faceGateGroupSync|msg|{}", msg);
            EmpGroupSyncDataParam dataParam = JSON.parseObject(msg, EmpGroupSyncDataParam.class);
            appFaceGateManager.handleGroup(dataParam);
        } catch (Exception ex) {
            logger.error("faceGateGroupSync|msg,消息处理失败", ex);
        }
    }


}
